// 定义表示记分牌的类
export default class ScorePanel {
  // 分数
  _score: number = 0;
  // 等级
  _level: number = 1;
  // 最大等级
  maxLevel: number = 10;
  // 每几分升一级
  upScore: number = 2;

  scoreEl: HTMLElement = <HTMLElement> document.querySelector("#score");
  levelEl: HTMLElement = document.querySelector("#level") as HTMLElement;

  constructor() {
    this.scoreEl.innerHTML = this._score + "";
    this.levelEl.innerHTML = this._level + "";
  }

  get score(): number {
    return this._score;
  }
  set score(val: number) {
    this._score = val;
    this.level = Math.floor(this.score / this.upScore) + 1;
    this.scoreEl.innerHTML = this._score + "";
  }

  get level(): number {
    return this._level;
  }
  set level(val: number) {
    if (val > this.maxLevel) {
      this._level = this.maxLevel;
    } else {
      this._level = val;
    }
    this.levelEl.innerHTML = this._level + "";
  }


}